<script type="text/javascript">
    $(document).ready(function(){
        $('#updatePermissions').click(function(){
            $('#frmPermissions').submit();
        })
    });
</script>
<div class="content-box">
    <div class="content-header">
        <h3>Permisos</h3>
    </div>

    <div id="groupList" class="divContainer">
        <form id="frmPermissions" action="/permission/update" method="post">
            <?php if (count($this->groups) != 0): ?>
                <table style="width: 100%">
                    <thead>
                    <th>Nombre de grupo</th>
                    <th>Permisos</th>
                    </thead>                

                    <?php foreach ($this->groups as $userGroup): ?>
                        <tr>
                            <td><strong><?php echo $userGroup->name; ?></strong></td>
                            <td>
                                <table>
                                    <thead>
                                    <th>Seccion</th>    
                                    <th>Sin Acceso</th>
                                    <th>Puede ver</th>
                                    <th>Puede ver y comentar</th>
                                    </thead>
                                    <tr>
                                        <td align="center">
                                            <strong><?php echo Object::getNameById(GroupPermission::findPermissionByGroup($userGroup->id)->object->id) ?></strong>
                                        </td>
                                        <td align="center">
                                            <input type="radio" <?php echo GroupPermission::findPermissionByGroup($userGroup->id)->permission == GroupPermission::HIDE ? 'checked="checked"' : '' ?> name="<?php echo $userGroup->id; ?>" value="0"/>
                                        </td>
                                        <td>
                                            <input type="radio" <?php echo GroupPermission::findPermissionByGroup($userGroup->id)->permission == GroupPermission::READ ? 'checked="checked"' : '' ?> name="<?php echo $userGroup->id; ?>" value="1"/>
                                        </td>
                                        <td>
                                            <input type="radio" <?php echo GroupPermission::findPermissionByGroup($userGroup->id)->permission == GroupPermission::READ_WRITE ? 'checked="checked"' : '' ?> name="<?php echo $userGroup->id; ?>" value="2"/>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    <?php endforeach; ?>
                </table>
            <?php else: ?>
                No hay Grupos
            <?php endif; ?>
            <p class="link">
                <a href="javascript:void(0)" id="updatePermissions"><span><span>Actualizar permisos</span></span></a>
            </p>
        </form>
    </div>

    <div style="clear: both"></div>
</div>